package com.zycfc.zsf.boot.mq.rabbitmq.consumer;

import org.springframework.amqp.core.*;
import java.lang.reflect.*;

public abstract class MessageHandler<T>
{
    public abstract void onMessage(final String p0, final String p1, final T p2, final MessageProperties p3) throws Exception;
    
    public abstract void onError(final Throwable p0);
    
    public final Type getType() {
        final Type superClass = this.getClass().getGenericSuperclass();
        if (superClass instanceof Class) {
            throw new IllegalArgumentException("\u5fc5\u987b\u8bbe\u7f6eMessageHandler\u4e2d\u7684\u6cdb\u578b\u7c7b\u578b");
        }
        final Type type = ((ParameterizedType)superClass).getActualTypeArguments()[0];
        if (type.getTypeName().equals(Object.class.getName())) {
            throw new IllegalArgumentException("MessageHandler\u4e2d\u7684\u6cdb\u578b\u7c7b\u578b\u4e0d\u80fd\u662fObject");
        }
        return type;
    }
}
